package com.inossem.warehousestorage_inossem.request.allocation;

import android.content.Context;

import com.google.gson.Gson;
import com.inossem.warehousestorage_inossem.bean.allocation.AllocationAllBatchRequestBean;
import com.inossem.warehousestorage_inossem.bean.outStorage.BatchBean;
import com.inossem.warehousestorage_inossem.constant.RequestConstant;
import com.inossem.warehousestorage_inossem.listener.GsonBeanListener;
import com.inossem.warehousestorage_inossem.listener.StringRequestListener;
import com.inossem.warehousestorage_inossem.manage.RequestManage;
import com.inossem.warehousestorage_inossem.model.StringResponse;
import com.inossem.warehousestorage_inossem.request.Request;

/**
 * TODO
 *
 * @author 詹建宇
 * @time on 2018/4/3 20:25
 * @email jianyu.zhan@inossem.com
 */
public class AllocationAllBatchRequest extends Request {

    public static String request(Context context, String mat_id, String location_id, String batch, GsonBeanListener gsonBeanListener) {
        String tag;
        String url = RequestManage.getUrl(context, RequestConstant.URL_ALLOCATION_OUT_ALL_BATCH);

        AllocationAllBatchRequestBean bean = new AllocationAllBatchRequestBean();
        bean.setMat_id(mat_id);
        bean.setLocation_id(location_id);
        bean.setBatch(batch);

        Gson gson = new Gson();
        String body = gson.toJson(bean);
        tag = RequestManage.getHttpsPostWithLoading(context, url, body, new StringRequestListener() {
            @Override
            public void onSuccess(StringResponse stringRequestResponse) {
                Gson gson = new Gson();
                String json = stringRequestResponse.getResponseInfo();
                BatchBean batchBean = gson.fromJson(json, BatchBean.class);
                excuteJsonBeanNew(context, batchBean, gsonBeanListener);
            }
        });
        return tag;
    }

}
